package com.wb.principle;

/**
 * 依赖关系传递的三种方式
 * 接口传递
 * 构造方法传递
 * setter方式传递
 *
 * @author 魏彪
 */
public class 依赖倒转原则_ {

    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
    }
}

class Email implements IReceiver {
    @Override
    public String getInfo() {
        return "电子邮件发送信息";
    }
}

interface IReceiver {
    String getInfo();
}

class Person {
    public void receive(IReceiver iReceiver) {
        System.out.println(iReceiver.getInfo());
    }
}

// 依赖关系传递的三种方式
// 1
interface IOpenAndClose {
    void open(ITV tv);
}

interface ITV {
    void play();
}

class OpenAndClose implements IOpenAndClose {

    @Override
    public void open(ITV tv) {
        tv.play();
    }
}